package test.solution;

import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int[] ary = new int[n];
            for (int i = 0; i < n; i++) {
                ary[i] = scanner.nextInt();
            }
            for (int i = 0; i < ary.length; i++) {
                int a = ary[i];
                if ((a & 0x1) == 0) {
                    int j = 0;
                    int tag = 1 << 31;
                    while ((a & tag) == 0) {
                        tag = tag >> 1;
                        j++;
                    }
                    int m = 0;
                    int ret = 0;
                    while (m + j < 32) {
                        int x = a & 1;
                        ret = ret << 1;
                        ret = ret | x;
                        a = a >> 1;
                        m++;
                    }
                    a = ret;
                }
                if (i == ary.length - 1) {
                    System.out.println(a);
                } else {
                    System.out.print(a + " ");
                }
            }//end for
        }//end while
    }
}